package com.eu.ebpm.engine.express.validator;

import com.eu.ebpm.engine.express.Variable;

/**
 * 
 * 类名称: BooleanTypeValidator 类描述:
 * 
 * @author 王晓华
 * @since 2013-12-23 下午03:43:56
 * @version v1.0
 */
public class BooleanTypeValidator implements TypeValidator<Boolean> {

	public Boolean transform(Object value) {
		
		if ("1".equals(value)) {
			return true;
		}
		
		if ("0".equals(value)) {
			return false;
		}
		
		return Boolean.valueOf((String) value);
	}

	public boolean checkVariable(Variable<Boolean> variable, Object condition) {
		
		if (condition instanceof Boolean) {
			return variable.getValue() == condition;
		}
		
		return false;
	}

}
